import request from '@/utils/request'
import {ILoginForm} from "@/types/login";

/**
 * 用户登录
 * @param {ILoginForm} data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
const loginApi = (data: ILoginForm) => {
    return request({
        url: '/login',
        method: 'post',
        data
    })
}


/**
 * 退出登录
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
const logoutApi = () => {
    return request({
        url: '/logout',
        method: 'post',
    })
}

/**
 * 获取验证码
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
const getCaptchaApi = () => {
    return request({
        url: '/captcha',
        method: 'get',
    })
}

/**
 * 验证验证码
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
const validCaptchaApi = (captcha:string|undefined) => {
    return request({
        url: '/captcha',
        method: 'post',
        data:{
            captcha
        }
    })
}
export {
    loginApi,
    logoutApi,
    getCaptchaApi,
    validCaptchaApi
}
